package cn.jy.careuplusdoctor.utils;

import com.ant.liao.GifView;
import com.ant.liao.GifView.GifImageType;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import cn.jy.careuplusdoctor.R;

public class LoadingCommon {

	public LoadingCommon(Context context) {
		setContext(context);
		initLoadingLayout();
	}
	
	public LoadingCommon(Context context,String text) {
		this.text = text;
		setContext(context);
		initLoadingLayout();
	}
	
	private String text = "loadding...";
	
	private GifView loadingGif;
	
	private TextView loadingTxt;
	
	private View loadingLayout;
	
	private Context context;

	public GifView getLoadingGif() {
		return loadingGif;
	}

	public void setLoadingGif(GifView loadingGif) {
		this.loadingGif = loadingGif;
	}

	public TextView getLoadingTxt() {
		return loadingTxt;
	}

	public void setLoadingTxt(TextView loadingTxt) {
		this.loadingTxt = loadingTxt;
	}

	public View getLoadingLayout() {
		return loadingLayout;
	}

	public void setLoadingLayout(View loadingLayout) {
		this.loadingLayout = loadingLayout;
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}
	
	private void initLoadingLayout(){
		LayoutInflater inflater = LayoutInflater.from(getContext().getApplicationContext());
		loadingLayout = inflater.inflate(R.layout.loading, null);
		loadingGif = (GifView) loadingLayout.findViewById(R.id.loadingGif);
		loadingGif.setGifImage(R.drawable.loadding_icon);
		loadingGif.setGifImageType(GifImageType.COVER);
		loadingTxt = (TextView) loadingLayout.findViewById(R.id.loadingTxt);
		loadingTxt.setText(text);
	}
	
}
